package com.five.admin.service.impl;

import com.five.admin.dao.ChapterMapper;
import com.five.admin.service.ChapterService;
import com.five.entity.Chapter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: star
 * @Date: 2021-05-21 14:08
 * 课程章节 service层实现类
 */
@Service
public class ChapterServiceImpl implements ChapterService {

    @Autowired
    private ChapterMapper chapterMapper;

    /**
     * 通过课程id搜索章节
     * @param chapter 课程id
     * @return 章节信息
     */
    @Override
    public List<Chapter> selectByCourseId(Chapter chapter) {
        List<Chapter> chapters = chapterMapper.selectByCourseId(chapter);
        return chapters;
    }

    /**
     * 添加章节信息
     * @param chapter
     */
    @Override
    public void insertChapter(Chapter chapter) {
        chapterMapper.insertChapter(chapter);
    }

    /**
     * 删除章节信息
     * @param id 章节id
     */
    @Override
    public void deleteChapter(Integer id) {
        chapterMapper.deleteChapter(id);
    }
}
